cmake_minimum_required(VERSION 3.6)
project(CGame++ VERSION 1.0.0)

set(CGAME_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set(CGAME_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set(CGAME_VERSION_PATCH ${PROJECT_VERSION_PATCH})

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -fvisibility=hidden")
# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
set(BUILD_SHARED_LIBS OFF)
message(STATUS "BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS}")
if(NOT CMAKE_BUILD_TYPE)
  set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
endif()
set(CGAME_ROOT ${CMAKE_CURRENT_LIST_DIR})

option(CGAME_EXAMPLES "Configure CMake to build examples (or not)" ON)

if(NOT DEFINED CGAME_TARGET_LOGGER)
# message("Set CGAME_TARGET_LOGGER info default[1]")
set(CGAME_TARGET_LOGGER "stdout")
endif()

if(${CMAKE_BUILD_TYPE} MATCHES "Debug")
set(CGAME_DEBUG 1)
else()
set(CGAME_DEBUG 0)
endif()

set(RAPIDJSON_BUILD_TESTS OFF CACHE BOOL "OFF DOCUMENTATION" FORCE)
add_subdirectory(${CGAME_ROOT}/lib/rapidyaml EXCLUDE_FROM_ALL)
add_subdirectory(${CGAME_ROOT}/lib/microtar EXCLUDE_FROM_ALL)

# set(EVENT__LIBRARY_TYPE "STATIC" CACHE STRING "")
# add_subdirectory(${CGAME_ROOT}/lib/libevent EXCLUDE_FROM_ALL)


configure_file(${CGAME_ROOT}/include/game_config.h.in ${CGAME_ROOT}/include/game_config.h)

include_directories(${CGAME_ROOT}/src
${CGAME_ROOT}/lib/rapidyaml/src
${CGAME_ROOT}/lib/rapidyaml/ext/c4core/src
${CGAME_ROOT}/lib/ccronexpr)


add_subdirectory(${CGAME_ROOT}/src)
get_directory_property(_parent PARENT_DIRECTORY)
if(_parent)
  set(CGAME_TARGET_PLATFORM ${CGAME_TARGET_PLATFORM} PARENT_SCOPE)
endif()

if(CGAME_EXAMPLES)
  add_subdirectory(${CGAME_ROOT}/example EXCLUDE_FROM_ALL)
endif()




